/*
 * Class ItemOption1
 *
 * Version 1.0
 *
 * Thursday, August 21, 2008
 *
 * Created by Palidino76
 */

package net.com.hydroPK.net.packethandler;

import net.com.hydroPK.Engine;
import net.com.hydroPK.model.Player;
import net.com.hydroPK.model.items.PlayerItems;

public class ItemOption2 implements Packet {
    /*
     * Handles first item options, excluding things such as eating and drinking.
     *
     * @param p          The Player which the frame should be handled for.
     * @param packetId   The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        int itemSlot = p.stream.readUnsignedWordBigEndianA();
        int interfaceId = p.stream.readUnsignedWord();
        int junk = p.stream.readUnsignedWord();
        int itemId = p.stream.readSignedWordA();
        PlayerItems pi = new PlayerItems();
        if (itemSlot < 0 || itemId < 0) {
            return;
        }
        switch (itemId) {
            case 12175:/*Spirit Wolf*/
                if (p.FamiliarID > 0) {
                    p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
                } else {
                    Engine.playerItems.deleteItem(p, 12047, itemSlot, 1);
                    p.getActionSender().sendMessage(p, "You summon  spirit wolf.");
                    p.getActionSender().setTab(p, 80, 662);
                    p.getActionSender().animateInterfaceId(p, 9805, 662, 3);
                    p.getActionSender().setNPCId(p, 6829, 662, 3);
                    Engine.newNPC(6829, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
                    //p.appendExperience(15, 23);
                }
                break;
		case 12171://DreadFowl
				if (p.skillLvl[23] > 3)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12043, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Dread Fowl");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6825, 663, 3);
						Engine.newNPC(6825, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(3000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 4 summoning to summon that.");
				}
				break;
			case 12187://Spirit Spider
				if (p.skillLvl[23] > 9)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12059, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Spirit Spider");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6841, 663, 3);
						Engine.newNPC(6841, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(5000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 10 summoning to summon that.");
				}
				break;
			case 13615:
			{

				Engine.playerItems.deleteItem(p, 13615, 1);
        			Engine.playerItems.addItem(p, 13616, 1);
				p.getActionSender().sendMessage(p, "You put the goggles down.");
				break;
			}
			case 13616:
			{

				Engine.playerItems.deleteItem(p, 13616, 1);
        			Engine.playerItems.addItem(p, 13615, 1);
				p.getActionSender().sendMessage(p, "You take the goggles off.");
				break;
			}
			case 13620:
			{

				Engine.playerItems.deleteItem(p, 13620, 1);
        			Engine.playerItems.addItem(p, 13621, 1);
				p.getActionSender().sendMessage(p, "You put the goggles down.");
				break;
			}
			case 13621:
			{

				Engine.playerItems.deleteItem(p, 13621, 1);
        			Engine.playerItems.addItem(p, 13620, 1);
				p.getActionSender().sendMessage(p, "You take the goggles off.");
				break;
			}
			case 13625:
			{

				Engine.playerItems.deleteItem(p, 13625, 1);
        			Engine.playerItems.addItem(p, 13626, 1);
				p.getActionSender().sendMessage(p, "You put the goggles down.");
				break;
			}
			case 13626:
			{

				Engine.playerItems.deleteItem(p, 13626, 1);
        			Engine.playerItems.addItem(p, 13625, 1);
				p.getActionSender().sendMessage(p, "You take the goggles off.");
				break;
			}


			case 11891://Thorny Snail
				if (p.skillLvl[23] > 12)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12019, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Thorny snail.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6806, 663, 3);
						Engine.newNPC(6806, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(6000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 13 summoning to summon that.");
				}
				break;

			case 12936://Spirit Tz-Kih
				if (p.skillLvl[23] > 21)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12808, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Spirit Tz-Kih.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7361, 663, 3);
						Engine.newNPC(7361, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(7000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 22 summoning to summon that.");
				}
				break;

			case 12201://Bronze Minotour
				if (p.skillLvl[23] > 35)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12073, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Bronze Minotour.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6853, 663, 3);
						Engine.newNPC(6853, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(8000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 36 summoning to summon that.");
				}
				break;

			case 12203://Iron Minotour
				if (p.skillLvl[23] > 45)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12075, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon an Iron Minotour.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6855, 663, 3);
						Engine.newNPC(6855, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(10000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 46 summoning to summon that.");
				}
				break;

			case 12205://Steel Minotour
				if (p.skillLvl[23] > 55)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12077, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Steel Minotour.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6857, 663, 3);
						Engine.newNPC(6857, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(12000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 56 summoning to summon that.");
				}
				break;

			case 12207://Mithril Minotour
				if (p.skillLvl[23] > 65)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12079, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Mithril Minotour.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6859, 663, 3);
						Engine.newNPC(6859, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(14000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 66 summoning to summon that.");
				}
				break;

			case 11879://Terror Bird
				if (p.skillLvl[23] > 52)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12007, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Spirit Terrorbird.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6794, 663, 3);
						Engine.newNPC(6794, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(16000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 52 summoning to summon that.");
				}
				break;

			case 12209://Adamant Minotour
				if (p.skillLvl[23] > 75)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12081, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Adamant Minotour.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6861, 663, 3);
						Engine.newNPC(6861, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(16000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 76 summoning to summon that.");
				}
				break;

			case 12211://Rune Minotour
				if (p.skillLvl[23] > 85)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12083, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Rune Minotour.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 6863, 663, 3);
						Engine.newNPC(6863, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(26000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 86 summoning to summon that.");
				}
				break;

			case 12930://Fire Titan
				if (p.skillLvl[23] > 78)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12802, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Fire Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7355, 663, 3);
						Engine.newNPC(7355, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(18000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 79 summoning to summon that.");
				}
				break;

			case 12932://Moss Titan
				if (p.skillLvl[23] > 78)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12804, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Moss Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7357, 663, 3);
						Engine.newNPC(7357, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(18000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 79 summoning to summon that.");
				}
				break;

			case 12934://Ice Titan
				if (p.skillLvl[23] > 78)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12806, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Ice Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7359, 663, 3);
						Engine.newNPC(7359, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(18000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 79 summoning to summon that.");
				}
				break;

			case 12660://Lava Titan
				if (p.skillLvl[23] > 82)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12788, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Lava Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7341, 663, 3);
						Engine.newNPC(7341, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(20000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 83 summoning to summon that.");
				}
				break;

			case 12648://Swamp Titan
				if (p.skillLvl[23] > 84)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12776, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Swamp Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7329, 663, 3);
						Engine.newNPC(7329, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(22500, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 85 summoning to summon that.");
				}
				break;



			case 12658://Geyser Titan
				if (p.skillLvl[23] > 88)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12786, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Geyser Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7339, 663, 3);
						Engine.newNPC(7339, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(25000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 89 summoning to summon that.");
				}
				break;

			case 12668://Abyssal Titan
				if (p.skillLvl[23] > 92)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12796, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Abyssal Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7349, 663, 3);
						Engine.newNPC(7349, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(28000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 93 summoning to summon that.");
				}
				break;

			case 12950://Iron Titan
				if (p.skillLvl[23] > 94)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12822, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon an Iron Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7375, 663, 3);
						Engine.newNPC(7375, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(30000, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 95 summoning to summon that.");
				}
				break;
			case 12662://Steel Titan
				if (p.skillLvl[23] > 98)
				{
					if (p.FamiliarID > 0)
					{
						p.getActionSender().sendMessage(p, "You cannot summon more than one familiar at a time.");
					}
					else
					{
						Engine.playerItems.deleteItem(p, 12790, itemSlot, 1);
						p.getActionSender().sendMessage(p, "You summon a Steel Titan.");
						p.getActionSender().setTab(p, 80, 663);
						p.getActionSender().animateInterfaceId(p, 9850, 663, 3);
						p.getActionSender().setNPCId(p, 7343, 663, 3);
						Engine.newNPC(7343, p.absX, p.absY + 1, p.heightLevel, p.absX + 1, p.absY + 1, p.absX + -1, p.absY + -1, false, p.playerId);
						p.appendExperience(10, 23);

					}
				}
				else
				{
					p.getActionSender().sendMessage(p, "You need at least level 99 summoning to summon that.");
				}
				break;
        }
    }
}
